package com.atnjupt.i18n;

import org.junit.Test;

import java.util.Locale;
import java.util.ResourceBundle;

/**
 * @author Wizarder
 * @create 2021-06-30 13:22
 */
public class I18n {
    @Test
    public void test(){
        //获取系统默认
        Locale aDefault = Locale.getDefault();
        System.out.println(aDefault);
        //获取中国地区
        Locale china = Locale.CHINA;
        //获取美国地区
        Locale us = Locale.US;
        System.out.println(us);
    }
    @Test
    public void test1(){
        //获取本地区locale对象
        Locale china = Locale.CHINA;
//        china = Locale.US;
        //通过指定的baseName和locale对象读取配置文件
        ResourceBundle resourceBundle = ResourceBundle.getBundle("i18n",china);

        System.out.println(resourceBundle.getString("username"));
        System.out.println(resourceBundle.getString("password"));
        System.out.println(resourceBundle.getString("sex"));
        System.out.println(resourceBundle.getString("age"));

    }

}
